$(function() {
    $(".issue_title").click(function() {
        $(this).next(".issue_options").toggle('fast');
    });
    $(".easyui-linkbutton").click(function() {
        $parent = $(this).parent();
        $bt_container = $parent.children("#backtrace_container");
        $("#backtrace_shower").html($bt_container.val());
        $("#backtrace_window").window('open');
    });
    $("a[class=jira]").click(function() {
        $parent = $(this).parent();
        $input = $parent.children("input[class=jira]");
        $input.toggle("fast");
    });
    $("#search_type").change(function() {
        var choosed = $(this).children('option:selected').val();
        $container = $("#search_content_container");
        var input_text = "";
        switch (choosed) {
            case 'crash_report':
            case 'backtrace':
                input_text = '<textarea name="content" type="text"></textarea>';
                break;
            default:
                input_text = '<input name="content" type="text">';
                break;
        }
        $container.html(input_text);
    });
    $("input[class=jira]").blur(function() {
        $parent = $(this).parent();
        $jira = $(this).val();
        $crash_id = $(this).attr("crash_id");
        $jira_display = $parent.children("#jira_display");
        var form_data = {
            id : $crash_id,
            jira : $jira
        };
        if ($jira == "") {
            return;
        }
        $.ajax({
            url : SITE_URL + "update_jira.php",
            type : 'post',
            data : form_data,
            success : function(msg, status) {
                var text = "";
                if (msg == "0") {
                    text = "update jira failed!";
                } else {
                    text = "update jira Success!";
                }
                $.messager.show({
                    title : 'Result',
                    msg : text,
                    timeout : 3000,
                    showType : 'slide'
                });
                $jira_display.html($jira);
                $jira_display.show();
                $jira_display.attr("href", JIRA_ADDRESS + $jira);
            }
        });
        $(this).toggle('fast');
    });
});
function searchCheck() {
    $("#backtrace_window").window('close');
    var content = $("input[name=content]").val();
    if (content == "") {
        $("#warning_input").show();
        $("input[name=content]").focus();
        return false;
    } else {
        return true;
    }
}